clear all
/*insert directory here*/


use fuelprices1934-2019, clear
keep year statefip pnatgas
gen group1=.
replace group1=pnatgas if statefip==48 | statefip==22 | statefip==35 | statefip==40
egen pnatgassynth=mean(group1), by(year)

replace group1=.
replace group1=pnatgas if year<1955 & year>1949
gen group2=.
replace group2=pnatgas if year>1989 & year<1995
gen group1b=.
replace group1b=pnatgassynth if year<1955 & year>1949
gen group2b=.
replace group2b=pnatgassynth if year>1989 & year<1995
egen treat1950s=mean(group1), by(statefip)
egen treat1990s=mean(group2), by(statefip)
egen synth1950s=mean(group1b)
egen synth1990s=mean(group2b)
gen diff90s=treat1990s-synth1990s
gen diff50s=treat1950s-synth1950s
gen statediff=(diff90s-diff50s)/35
gen pnatgascounter=pnatgas
replace pnatgascounter=pnatgassynth+diff50s+statediff*(year-1954) if year>1954 & year<1990
sort statefip year
keep statefip year pnatgascounter
drop if year<1960
merge 1:1 year statefip using fuelprices1960-19
drop _merge


